package gold.digger;

import gold.utils.InputUtil;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC1189 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int maxNumberOfBalloons(String text) {
            int[] cnt = new int[26];
            for (int i = 0; i < text.length(); i++) {
                cnt[text.charAt(i) - 'a']++;
            }

            // balloon
            int ans = Integer.MAX_VALUE;
            ans = Math.min(ans, cnt['b' - 'a']);
            ans = Math.min(ans, cnt['a' - 'a']);
            ans = Math.min(ans, cnt['l' - 'a'] / 2);
            ans = Math.min(ans, cnt['o' - 'a'] / 2);
            ans = Math.min(ans, cnt['n' - 'a']);
            return ans;
        }
    }

    public void run() {
        Solution solution = new Solution();
        System.out.println(solution.maxNumberOfBalloons("nlaebolko"));
        System.out.println(solution.maxNumberOfBalloons("loonbalxballpoon"));
        System.out.println(solution.maxNumberOfBalloons("leetcode"));
    }

    public static void main(String[] args) throws Exception {
        LC1189 an = new LC1189();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
